import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
import { Indicator } from 'mint-ui'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isTabbarShow: true,
    comingList: [],
    nowplayingList: [],
    cinemaList: [],
    isDetailBuyShow: true,
    ticketList: [],
    cinedata: '',
    showdate: '',
    filminfo: [],
    showCinemas: [],
    cinemainfo: [],
    filmdata: []
  },
  mutations: {
    HideMaizuoTabbar (state, data) {
      state.isTabbarShow = data
    },
    ShowMaizuoTabbar (state, data) {
      state.isTabbarShow = data
    },
    comingListMutation (state, data) {
      state.comingList = data
    },
    NowplayingListMutation (state, data) {
      state.nowplayingList = data
    },
    CinemaListMutation (state, data) {
      state.cinemaList = data
    },
    TicketListMutation (state, data) {
      state.ticketList = data
    },
    CinemaldsMutation (state, data) {
      state.Cinemalds = data
    }

  },
  actions: {
    getComingListAction (store) {
      axios({
        url: 'https://m.maizuo.com/gateway?cityId=440100&pageNum=1&pageSize=10&type=2&k=3700391',
        headers: {
          'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.0.4","e":"1601368144305732951998465"}',
          'X-Host': 'mall.film-ticket.film.list'
        }
      }).then(res => {
        // console.log(res.data)
        store.commit('comingListMutation', res.data.data.films)
      })
    },
    getNowplayingListAction (store) {
      // console.log(data)
      axios({
        url: 'https://m.maizuo.com/gateway?cityId=440100&pageNum=1&pageSize=10&type=1&k=7107928',
        headers: {
          'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.0.4","e":"1601368144305732951998465"}',
          'X-Host': 'mall.film-ticket.film.list'
        }
      }).then(res => {
        store.commit('NowplayingListMutation', res.data.data.films)
      })
    },
    getCinemaListAction (store) {
      axios({
        url: 'https://m.maizuo.com/gateway?cityId=440100&ticketFlag=1&k=3995053',
        headers: {
          'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.0.4","e":"1601368144305732951998465","bc":"440100"}',
          'X-Host': 'mall.film-ticket.cinema.list'
        }
      }).then(res => {
        // this.datalist = res.data.data.cinemas
        store.commit('CinemaListMutation', res.data.data.cinemas)
        console.log(res.data.data.cinemas)
      })
    }

  },
  modules: {
  }
})
